Page({
  data: {
    isFreeUponLease: true, // 是否租完即送
    order_ensure_amount: '',
    order_goods_insurance: '',
    goods_lease_way_id: '',
    order_ensure_amount_status: '',
    buy_money: '', //原买断价
    actualPayment: '' // 到期实付买断金
  },
  onLoad(option) {
    let {
      order_ensure_amount,
      order_goods_insurance,
      goods_lease_way_id,
      order_ensure_amount_status,
      buy_money
    } = option
    goods_lease_way_id = parseInt(goods_lease_way_id)
    buy_money = Number(buy_money)
    order_ensure_amount = Number(order_ensure_amount)

    if(goods_lease_way_id === 4 || goods_lease_way_id === 5) {
      this.setData({
        isFreeUponLease: false
      })
    } else {
      this.setData({
        isFreeUponLease: true
      })
    }

    const actualPayment = buy_money - order_ensure_amount
    this.setData({
      order_ensure_amount,
      order_goods_insurance,
      goods_lease_way_id,
      order_ensure_amount_status,
      buy_money,
      actualPayment: actualPayment.toFixed(2)
    })
    my.setNavigationBar({
      frontColor: '#000000',
      backgroundColor: '#ff0000',
    })
  },
});
